package com.netty.demo10;

import java.nio.ByteBuffer;

/**
 * Created by Lxk on 2020/2/2.
 */
public class NioTest7 {
    //只读buffer是从一般buffer得来，只允许进行读取，类型同一般buffer不一样
    public static void main(String[] args) {
        ByteBuffer buffer = ByteBuffer.allocate(10);
        System.out.println(buffer.getClass());
        for(int i = 0;i < buffer.capacity(); i++){
            buffer.put((byte)i);
        }
        ByteBuffer byteBufferReadOnly = buffer.asReadOnlyBuffer();
        System.out.println(byteBufferReadOnly.getClass());
        byteBufferReadOnly.position(0);
        byteBufferReadOnly.put((byte)2);
    }

}
